package com.ruoyi.web.controller.combat.apprisk;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.annotation.Anonymous;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.combat.domain.apprisk.CombatApplicationType;
import com.ruoyi.combat.service.apprisk.ICombatApplicationTypeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 应用类别Controller
 * 
 * @author ruoyi
 * @date 2025-03-28
 */
@RestController
@RequestMapping("/combat/appType")
public class CombatApplicationTypeController extends BaseController
{
    @Autowired
    private ICombatApplicationTypeService combatApplicationTypeService;

    /**
     * 查询应用类别列表
     */
    @PreAuthorize("@ss.hasPermi('combat:appType:list')")
    @GetMapping("/list")
    public TableDataInfo list(CombatApplicationType combatApplicationType)
    {
        startPage();
        List<CombatApplicationType> list = combatApplicationTypeService.selectCombatApplicationTypeList(combatApplicationType);
        return getDataTable(list);
    }

    /**
     * 导出应用类别列表
     */
    @PreAuthorize("@ss.hasPermi('combat:appType:export')")
    @Log(title = "应用类别", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CombatApplicationType combatApplicationType)
    {
        List<CombatApplicationType> list = combatApplicationTypeService.selectCombatApplicationTypeList(combatApplicationType);
        ExcelUtil<CombatApplicationType> util = new ExcelUtil<CombatApplicationType>(CombatApplicationType.class);
        util.exportExcel(response, list, "应用类别数据");
    }

    /**
     * 获取应用类别详细信息
     */
    @PreAuthorize("@ss.hasPermi('combat:appType:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(combatApplicationTypeService.selectCombatApplicationTypeById(id));
    }

    /**
     * 新增应用类别
     */
    @Anonymous
    @PostMapping
    public AjaxResult add(@RequestBody CombatApplicationType combatApplicationType)
    {
        return toAjax(combatApplicationTypeService.insertCombatApplicationType(combatApplicationType));
    }

    /**
     * 修改应用类别
     */
    @PreAuthorize("@ss.hasPermi('combat:appType:edit')")
    @Log(title = "应用类别", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CombatApplicationType combatApplicationType)
    {
        return toAjax(combatApplicationTypeService.updateCombatApplicationType(combatApplicationType));
    }

    /**
     * 删除应用类别
     */
    @PreAuthorize("@ss.hasPermi('combat:appType:remove')")
    @Log(title = "应用类别", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(combatApplicationTypeService.deleteCombatApplicationTypeByIds(ids));
    }
}
